package io.kimmking.dubbo.demo.provider;

//import com.alibaba.csp.sentinel.slots.block.RuleConstant;
//import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
//import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.Collections;

@EnableDubbo
@SpringBootApplication(scanBasePackages = {"io.kimmking.dubbo.demo.provider","com.ylbl"})
//@EnableEurekaClient
public class DubboServerApplication {

	public static void main(String[] args) throws InterruptedException{
//		initFlowRule();
		SpringApplication.run(DubboServerApplication.class, args);
//		new SpringApplicationBuilder()
//				.sources(DubboServerApplication.class)
//				.web(WebApplicationType.NONE)
//				.run(args);
//		CountDownLatch countDownLatch = new CountDownLatch(1);
//		countDownLatch.await();
	}

//	private static void initFlowRule() {
//		FlowRule flowRule = new FlowRule();
//		//针对具体的方法限流,限流粒度可以是服务接口和服务方法两种粒度
//		//若是限流方法粒度则resourceName为接口全限定名:方法签名
//		flowRule.setResource("io.kimmking.dubbo.common.entity.UserService");
//		flowRule.setCount(2);//限流阈值 qps=10
//		flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);//限流阈值类型（QPS 或并发线程数）
//		flowRule.setLimitApp("default");//流控针对的调用来源，若为 default 则不区分调用来源
//		// 流量控制手段（直接拒绝、Warm Up、匀速排队）
//		flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
//		FlowRuleManager.loadRules(Collections.singletonList(flowRule));
//	}

}
